package com.x.crm.dao;

import com.x.crm.model.FollowFixture;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class FollowFixtureDao extends BaseDao{


	private final static String baseSelectFollowFixtureListSql = "SELECT * FROM  CRM_FOLLOW_FIXTURE  I " +
			"WHERE 1=1 ";

	public List<FollowFixture> selectFollowFixtureList(FollowFixture followFixture) throws Exception {
		StringBuilder sb = new StringBuilder(baseSelectFollowFixtureListSql);
		List<Object> params = new ArrayList<Object>();
		searchBasicCondition(followFixture, sb, params);
		sb.append(" ORDER BY I.FOLLOW_FIXTURE_CREATE_TIME DESC");
		return this.queryForList(sb.toString(), FollowFixture.class, params, followFixture);
	}


	private void searchBasicCondition(FollowFixture followFixture, StringBuilder sb, List<Object> params) {
		if (this.isString(followFixture.getIntentionId())) {
			sb.append("AND I.INTENTION_ID = ? ");
			params.add(followFixture.getIntentionId());
		}
	}


}
